package com.yanqu.road.entity.activity.bulletscreen;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.DataStatus;

import java.util.ArrayList;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_u_activity_bullet_screen_user_data")
public class BulletScreenUserData extends DataObject {

    @FieldTypeAnnotation(desc = "用户ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "活动ID", update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "重置时间")
    private long resetTime;

    @FieldTypeAnnotation(desc = "今日可弹幕次数")
    private int canBarrageTimes;

    @FieldTypeAnnotation(desc = "购买弹幕次数")
    private int buyBarrageTimes;

    @FieldTypeAnnotation(desc = "历史已读弹幕id")
    private long readContentId;

    @FieldTypeAnnotation(desc = "实时已读弹幕id")
    private List<Long> readContentIdList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "最后已读时间")
    private long lastReadTime;

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public void setResetTime(long resetTime) {
        if (this.resetTime != resetTime) {
            this.resetTime = resetTime;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public long getResetTime() {
        return resetTime;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }


    public int getCanBarrageTimes() {
        return canBarrageTimes;
    }

    public void setCanBarrageTimes(int canBarrageTimes) {
        if (this.canBarrageTimes != canBarrageTimes) {
            this.canBarrageTimes = canBarrageTimes;
            setUpdateOption();
        }
    }

    public int getBuyBarrageTimes() {
        return buyBarrageTimes;
    }

    public void setBuyBarrageTimes(int buyBarrageTimes) {
        if (this.buyBarrageTimes != buyBarrageTimes) {
            this.buyBarrageTimes = buyBarrageTimes;
            setUpdateOption();
        }
    }

    public long getReadContentId() {
        return readContentId;
    }

    public void setReadContentId(long readContentId) {
        if (this.readContentId != readContentId) {
            this.readContentId = readContentId;
            setUpdateOption();
        }
    }

    public List<Long> getReadContentIdList() {
        return readContentIdList;
    }

    public void setReadContentIdList(List<Long> readContentIdList) {
        this.readContentIdList = readContentIdList;
        setUpdateOption();
    }

    public void addRealTimeReadContentId(long id){
        if(!this.readContentIdList.contains(id)) {
            this.readContentIdList.add(id);
            setUpdateOption();
        }
    }

    public void removeRealTimeReadContentId(long id){
        if(this.readContentIdList.contains(id)) {
            this.readContentIdList.remove(id);
            setUpdateOption();
        }
    }

    public long getLastReadTime() {
        return lastReadTime;
    }

    public void setLastReadTime(long lastReadTime) {
        if(this.lastReadTime != lastReadTime) {
            this.lastReadTime = lastReadTime;
            setUpdateOption();
        }
    }
}
